<!DOCTYPE HTML>
<html>
<head>
<title>global HTML page</title>
<script type="text/javascript">

/*
// This code listens for presses on the toggle button,
// but because it's impossible to visualize the state of the extension in a user-friendly way (e.g. a label on the button)
// We don't use it (yet/anymore)

// Listen for button presses
safari.application.addEventListener("command", trigger, false);

function toggle(event){
	if(event.command == 'toggle'){
		safari.extension.settings.active = !safari.extension.settings.active;
	}
}
*/

// Send the requested info back to the requester
function sendSettings(event) {
	
	// We are only interested in events requesting settings
	if(event.name != 'getSettings'){
		// another event happened, exit
		return;
	}
	
	// create response	
	var response = {};
	// Read the institute, username and password from the settings
	response.institute = safari.extension.settings.institute;
	response.username = safari.extension.secureSettings.username;
	response.password = safari.extension.secureSettings.password;
	response.active = safari.extension.settings.active;
	// Send the requested data back, using the name of the requested data as name for the response
	event.target.page.dispatchMessage("settings", response);
}

// Listen for messages and pass them to the sendSettings function
safari.application.addEventListener("message",sendSettings,false);

</script>
</head>
<body>
</body>
</html>